<template>
  <div>
    <h1>关注管理</h1>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column
        prop="userName"
        label="用户名称"
        width="180"
      ></el-table-column>
      <el-table-column
        prop="attentionNums"
        label="粉丝数量"
        width="180"
      ></el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        :page-sizes="[1, 3, 5, 7]"
        :current-page="pageNum"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
  import { getAttentionList } from '@/api/bbs'

  export default {
    name: 'Index',
    data() {
      return {
        pageNum: 0,
        pageSize: 2,
        total: 20,
        tableData: [
          {
            userName: '',
            attentionNums: '',
          },
        ],
      }
    },
    mounted() {
      this.getAttentionList()
    },
    methods: {
      getAttentionList() {
        getAttentionList(this.pageNum, this.pageSize).then((res) => {
          console.log(res)
          this.tableData = res.data
          this.total = res.total
        })
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`)
        this.pageSize = val
        this.getAttentionList()
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`)
        this.pageNum = val
        this.getAttentionList()
      },
    },
  }
</script>

<style scoped></style>
